package top.dancun.eascourse.feign.service;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import top.dancun.common.entity.RoleEntity;
import top.dancun.common.utils.R;
import top.dancun.eascourse.feign.ShiroFeign;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
public class SysFeignService  {

    @Autowired
    private ShiroFeign shiroFeign;


    public List<RoleEntity> ListMyRole() {
        R  r = shiroFeign.ListMyRole();
        List<RoleEntity> roleEntityList = new ArrayList<>();
        if ("20000".equals(r.get("code").toString())) {
            List<Map<String,String>> roleMap = (List<Map<String, String>>) r.get("data");
            roleMap.forEach(map->{
                RoleEntity role = JSON.parseObject(JSON.toJSONString(map), RoleEntity.class);
                roleEntityList.add(role);
            });
        }
        return roleEntityList;
    }
}
